<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="template-head.jsp" />
<jsp:include page="template-body.jsp" />
<div class="hero-unit">
<div class="container">
<jsp:include page="errors.jsp"/>
<div class="span12">
<div id="mailinglistpage">
	<h3>Mailing List</h3>
	<div id="mailinglistbody">
	<c:choose>
		<c:when test="${mailinglistbody == 'init'}">
			<c:choose>
				<c:when test="${empty mailinglist}">
					<h4>You do not have a mailing list yet. Would you like to <a href="mailinglist.do?button=Create">create one?</a></h4>
				</c:when>
				<c:otherwise>
					<h4>Following is the list of mailing lists that you have created.</h4>
					<c:forEach var="ml" items="${mailinglist}">
						<h4><a href="mailinglist.do?value=${ml.name}&button=View">${ml.name}</a></h4>
					</c:forEach>
					<br/>
					<h4>Would you like to <a href="mailinglist.do?button=Create">create more?</a></h4>
				</c:otherwise>
			</c:choose>
		</c:when>
		<c:when test="${mailinglistbody == 'create'}">
		<form id="mailinglistform" method="post" action="mailinglist.do">
			<div id="mailinglistchoice">
				<p>Enter the name of mailing list</p>
				<input type="text" name="name" value=""><br/><br/>
				<input type="submit" name="button" class="btn btn-danger" value="Import mailing list from file"><br/><br/>
				<input type="submit" name="button" class="btn btn-success" value="Create from scratch"><br/><br/>
				<input type="submit" name="button" class="btn btn-inverse" value="Back">
 			</div>
		</form>
		</c:when>
		
		<c:when test="${mailinglistbody == 'import'}">
		<h3>Import Mailing List file</h3>
		<form id="importmailinglistform" method="post" action="mailinglist.do" enctype="multipart/form-data">
			<input type="file" name="file" size="50"><br/>
			<input type="submit" name="button" class="btn btn-primary" value="Import"><br/><br/>
		</form>
		</c:when>
		
		<c:when test="${mailinglistbody == 'associate'}">
		<form id="createsurveymailinglist" method="post" action="mailinglist.do">
			<p>Select the mailing list to be associated with</p>
			<select class="type" name="type">
				<c:forEach var="ml" items="${mailinglist}">
					<option>${ml.name}</option>
				</c:forEach>
			</select><br/><br/>
			<input type="submit" name="button" class="btn btn-primary" value="Associate with this mailing list"><br/><br/>
		</form>
		</c:when>
		
		<c:when test="${mailinglistbody == 'complete' || mailinglistbody == 'view'}">
		<form id="mailinglistcomplete" method="post" action="mailinglist.do">
			<c:if test="${mailinglistbody == 'complete'}">
				<p>Upload complete. Following is the content of uploaded mailing list.</p>
			</c:if>
			<table>
			<c:forEach var="mld" items="${mailinglistdata}">
				<tr>
					<td>${mld.respid}</td>
					<td>${mld.email}</td>
				</tr>
			</c:forEach>
			</table>
			<input type="submit" name="button" class="btn btn-primary" value="Ok"><br/><br/>
		</form>
		</c:when>
		
		<c:when test="${mailinglistbody == 'associatecomplete'}">
		<form id="mailinglistcomplete" method="post" action="mailinglist.do">
			<p>Survey successfully associated with mailing list named ${ml}.</p>
			<input type="submit" name="button" class="btn btn-primary" value="Ok"><br/><br/>
		</form>
		</c:when>
		
		<c:otherwise>
		<c:if test="${mailinglistbody == 'createmore'}">
		<p>Added to mailing list.</p>
		</c:if>
		<form id="mailinglistform" method="post" action="mailinglist.do">
			<div id="mailinglisttext">
				<p>Enter the name of respondent.</p>
				<input type="text" name="userid" value=""><br/><br/>
				<p>Enter the email of respondent.</p>
				<input type="text" name="email" value=""><br/><br/>
			</div>
			<div id="mailinglistbutton">
				<table>
					<tr>
						<td><input type="submit" name="button" class="btn btn-success"  value="Create More"></td>
					</tr>
					<tr>
						<td><input type="submit" name="button" class="btn btn-success"  value="Finish"></td>
					</tr>
					<tr>
						<td><input type="submit" name="button" class="btn btn-inverse"  value="Back"></td>
					</tr>
				</table>
			</div>
		</form>
		</c:otherwise>
	</c:choose>
	</div>
</div>
</div>
</div>
</div>
<!--Create another space for contents' extension  -->
	<div class="container2">
	
	
 	</div>
<jsp:include page="template-foot.jsp" /> 